Add which-key-dump-bindings
authorJustin Burkett <justin@burkett.cc>
Sat, 18 May 2019 01:57:18 +0000 (21:57 -0400)
committerJustin Burkett <justin@burkett.cc>
Sat, 18 May 2019 01:57:18 +0000 (21:57 -0400)
Fixes #209

which-key.el

index 6980b78c5b9527e6a797c39880f74fef6a2207d4..f4b15c4806adabbffbeae4b72b5ad918cc607465 100644 (file)
@@ -2278,6 +2278,21 @@ current evil state. "
          "Major-mode bindings")
       (message "which-key: No map named %s" map-sym))))
 
+;;;###autoload
+(defun which-key-dump-bindings (prefix buffer-name)
+  "Dump bindings from PREFIX into buffer named BUFFER-NAME.
+
+PREFIX should be a string suitable for `kbd'."
+  (interactive "sPrefix: \nB")
+  (let* ((buffer (get-buffer-create buffer-name))
+         (keys (which-key--get-bindings (kbd prefix))))
+    (with-current-buffer buffer
+      (point-max)
+      (save-excursion
+        (dolist (key keys)
+          (insert (apply #'format "%s%s%s\n" key)))))
+    (switch-to-buffer-other-window buffer)))
+
 ;;;###autoload
 (defun which-key-undo-key (&optional _)
   "Undo last keypress and force which-key update."